// gulp 的入口文件  gulp的基础用法

exports.foo = done => {
    console.log('foo task working~')  
    /* 
    * 直接运行yarn gulp foo 会报错 The following tasks did not complete: foo  Did you forget to signal async completion?
    * 这是因为gulp中取消了同步代码的模式， 约定每个任务都是异步任务
    * 需要去手动调用一个回调函数，标识此任务已完成, foo传一个形参
    */
   done() // 标识已经执行完毕
}

exports.default = done => {
    console.log('default task working~')
    done()
}


const  { series, parallel } = require('gulp')
// 以下未被导出的任务叫私有任务
const task1 = done => {
    setTimeout(() => {
        console.log('task1 task working~');
        done();
    }, 1000)
}

const task2 = done => {
    setTimeout(() => {
        console.log('task2 task working~');
        done();
    }, 1000)


}

const task3 = done => {
    setTimeout(() => {
        console.log('task3 task working~');
        done();
    }, 1000)
}

// exports.tasks = series(task1, task2, task3) // 依次被执行 串行

exports.tasks = parallel(task1, task2, task3) // 并行 同时进行